// 新建system
const path = require("path")
const fs = require("fs");

// assets 目录
const assetsDir = path.join(path.dirname(__dirname), "assets")
const gameDir = path.join(assetsDir, "script", "game")
// 模块名
const mod = process.argv[2]
const systemName = process.argv[3]
// 说明
const comment = process.argv[4] || ''
if (!mod || !systemName || !comment) {
    console.error("使用方法, tools 目录下运行: node newSystem 游戏模块 system组件名 system说明")
    process.exit(1)
}

// 首字母大写
const clsName = systemName.charAt(0).toUpperCase() + systemName.slice(1) + "System"

const text = `import {ecs} from "db://oops-framework/libs/ecs/ECS";

// ${comment}
export class ${clsName} extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
    filter(): ecs.IMatcher {
        throw new Error("to be implemented")
        // return ecs.allOf()
    }

    entityEnter(entity: ecs.Entity) {
    }

}
`

fs.writeFileSync(path.join(gameDir, mod, "bll", systemName + "System.ts"), text)